package com.learn.finished;

public class num_1716 {
    public static void main(String[] args) {
        System.out.println(totalMoney(4));
    }
    public static int totalMoney(int n) {
        //判断这是第几周
        int week=n/7;
        //判断这是第几天
        int day=n%7;
        //存满了一周的话,价钱应该如何计算
        int sum=0;
        if (week>0){
            //n/7>0表示存了一周以上
            //现在如何把每周的钱都加起来？
            for (int i = 1; i <= week; i++) {
                sum+=(i+3)*7;
            }
            return ((week+1)+week+day)*day/2+sum;
        }
        //如果未存满一周，那未满的那周价格又如何计算
        //对7求余，判断多出来多少天,然后再求n/7
        else if (n % 7!=0) {

            //根据规律，可以发现，第几周，周一就存几块
            //所以未满一周的价格可以为（周一+第n天）*n天/2
            return ((week+1)+week+day)*day/2+sum;
        }
        return 0;

//        if (n % 7 == 0) {
//            int week=n/7;
//            return (week+3)*7;
//        } else {
//            int week = n / 7;
//            int begin = n % 7;
//            if (week > 0) {
//                return (week + 1) * 7 + (((week + 1) + (week + 1 + begin)) * begin) / 2;
//            }
//        }

    }
}
